package de.koller.reason.gui;

import de.koller.oceanFramework.gl.util.ParticleTexture;
import de.koller.oceanFramework.tree.Child;
import de.koller.oceanFramework.tree.Sea3X;
import de.koller.reason.gui.component.button.ButtonHandler;
import de.koller.reason.gui.component.button.IButton;
import de.koller.reason.gui.component.textfield.TextFieldHandler;
import de.koller.reason.gui.renderObj.GlyphRendering;
import de.koller.reason.gui.renderObj.IRenderObject;
import de.koller.reason.gui.renderObj.IVolatileRenderObject;
import de.koller.reason.gui.textureObj.TextureObject;
import java.util.HashSet;
import java.util.Set;
import org.lwjgl.opengl.GL11;

public class GUIRoot extends Sea3X {

	private TextureObject basicTexture;
	@Child protected final GlyphRendering volatileGlyph = new GlyphRendering();
	@Child protected final GlyphRendering staticGlyph = new GlyphRendering();
	
	public final Set<IRenderListener> renderListeners = new HashSet<>();
	public final Set<IRenderObject> volatileGlyphRenderObj = new HashSet<>();
	public final Set<IRenderObject> staticGlyphRenderObj = new HashSet<>();
	public final Set<IRenderObject> basicRenderObjs = new HashSet<>();
	public final Set<IButton> buttons = new HashSet<>();
	
	@Child public final RenderRoot renderRoot = new RenderRoot();
	@Child private final GUIInput input = new GUIInput();
	private final ButtonHandler buttonHandler = new ButtonHandler();
	public final TextFieldHandler textFieldHandler = new TextFieldHandler();
	
	@Override
	protected void init() {
		super.init();
		
		ParticleTexture.MAG_FILTER = GL11.GL_NEAREST;
		ParticleTexture.MIN_FILTER = GL11.GL_NEAREST;
		basicTexture = TextureObject.create( "data/texture.png" );
		
		staticGlyph.getScreen().setClearable( false );
	}

	@Override
	protected void update( int elapsedTime ) {
		super.update( elapsedTime );
		
		buttonHandler.update( buttons, input );
	}
	
	public TextureObject getBasicTexture() {
		return basicTexture;
	}

	public GlyphRendering getStaticGlyph() {
		return staticGlyph;
	}

	public GlyphRendering getVolatileGlyph() {
		return volatileGlyph;
	}
	
}
